package com.ruoyi.wlw.socket;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

public class BootNettyChannelInitializer <SocketChannel> extends ChannelInitializer<Channel> {

    @Override
    protected void initChannel(Channel channel) throws Exception {
        // ChannelOutboundHandler，依照逆序执行
        channel.pipeline().addLast("encoder", new NettyMessageEncoder());

        // 属于ChannelInboundHandler，依照顺序执行
        channel.pipeline().addLast("decoder", new NettyMessageDecoder());
        /**
         * 自定义ChannelInboundHandlerAdapter
         */
        channel.pipeline().addLast(new BootNettyChannelInboundHandlerAdapter());
    }
}
